package com.qunduikj.sjb.sdk.model.api;

import com.litesuits.sdk.model.Model;

/**
 * base class for api response model.
 *
 * data : {"code":"0","errorMsg":"正常","object":null,"total":null,"success":true}
 *
 * @author MaTianyu(http://litesuits.com) on 2015-05-28
 */
public class ApiModel<T> implements Model {
    public int code;//返回值
    public boolean ok;//是否成功
    public String message;//错误信息
    public int total;
    public T result;

    public boolean isSuccess() {
        return ok;
    }

    public boolean hasResult() {
        return ok && result != null;
    }

    public int getTotal() {
        return total;
    }

    @Override
    public String toString() {
        return "ApiModel{" +
               "code=" + code +
               ", ok=" + ok +
               ", message='" + message + '\'' +
               ", total=" + total +
               ", object=" + result +
               '}';
    }
}
